<template>
    <div>
      <textarea name="editor" id="editor" v-model="data">{{data}}</textarea>
    </div>
</template>

<script>
    export default {
      name: "showMD",
      data() {
        return {
          msg: 'Hello World',
          data: '',
        }
      },
      //编译好的HTML挂载到页面完成后执行的事件钩子，此钩子函数中一般会做一些axios请求获取数据。
      mounted: function () {
        this.M12();
      },
      methods: {
        //执行钩子
        M12() {
          // 保证this作用域相同
          let that = this;
          //构建 POST 参数
          let showMdIndex = new FormData();
          showMdIndex.append("Index","不要问我为啥不用GET！");
          this.axios.post("/showDataSelect",showMdIndex)
            .then(function (response) {
              if (response.status === 200){
                that.data = decodeURIComponent(response.data.IndexData);
                console.log("获取data值",that.data);
                let mditor = Mditor.fromTextarea(document.getElementById('editor'));
                mditor.sqlit =false;
                mditor.fullscreen = true;
                console.log("执行成功~");
                mditor.value = that.data;
              }else {
                alert("M12爆炸！")
              }
            })
            .catch(function (error) {
              alert("你干什么？？？");
              console.log(error)
            });


        },
      }
    }
</script>

<style scoped>

</style>
